DROP TRIGGER T_ID_TRI;
DROP SEQUENCE T_ID_SEQ;
DROP TABLE T;

--创建表
CREATE TABLE T(
ID INT PRIMARY KEY,
FIELD VARCHAR2(10) NOT NULL
);

--创建序列
CREATE SEQUENCE T_ID_SEQ
INCREMENT BY 1
START WITH 1
MAXVALUE 256
CYCLE
NOCACHE;

--创建触发器
CREATE TRIGGER T_ID_TRI BEFORE
INSERT ON T FOR EACH ROW WHEN(NEW.ID IS NULL)
BEGIN
SELECT T_ID_SEQ.NEXTVAL INTO:NEW.ID FROM DUAL;
END;
